package com.wanxi.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Li
 * @Date 2023/5/6 15:29
 */
@Data
@NoArgsConstructor
@Builder
@ApiModel(value = "统一返回JSON格式",description = "将数据以json格式返回给前端")
public class ResultDto {
    /**
     * 返回代码 200表示正确，100表示错误
      */
    @ApiModelProperty(value = "返回代码",example = "200")
    private Integer code;
    /**
     * 返回信息
      */
    @ApiModelProperty(value = "返回信息",example = "success")
    private String msg;
    /**
     * 影响数据的条数
     */
    @ApiModelProperty(value = "影响条数",example = "1")
    private Integer count;
    /**
     * 返回给前端的数据
     */
    @ApiModelProperty(value = "返回的数据",example = "data:{张明，李华}")
    private Object data;

    public ResultDto(Integer code, String msg, Integer count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public ResultDto(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultDto(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
